<template>
  <div class="container" :class="{'have_top': showTop}">
    <top v-if='showTop' :toptext='pageName' @='backPage()'></top>
    <route v-ref:route ></route>
  </div>
</template>
<script>
export default {
  title: 'home',
  data () {
    return {
      pageName: '',
      showback: 'false',
      nowPage: 'home-page',
      showTop: false
    }
  },
  events: {
    'menu' (param) {
      this.showTop = true
      this.pageName = param
      if (param === '计划下载') {
        this.$refs.route.init('plan-down')
      } else if (param === '表单上传') {
        this.$refs.route.init('plan-update')
      } else if (param === '抄表管理') {
        this.$refs.route.init('read-meter')
      } else if (param === '抄表记录') {
        this.$refs.route.init('read-meter-info')
      } else {
        this.showTop = false
        this.$refs.route.init('home')
      }
    },
    'changepage' (val, param) {
      if (param === 'save') {
        window.currentPage = '抄表录入'
      } else {
        window.currentPage = undefined
      }
      this.$refs.route.init('phone-hand', {data: val, type: param})
    },
    'returnPage' () {
      if (window.currentPage && window.currentPage === '抄表录入') {
        this.showTop = true
        this.pageName = '抄表管理'
        window.currentPage = undefined
        this.$refs.route.init('read-meter')
        return
      }
      this.showTop = false
      this.$refs.route.init('home')
    },
    'hand-success' (type) {
      HostApp.alert('抄表成功')
      if (type === 'save') {
        this.$refs.route.init('read-meter')
      } else {
        this.$refs.route.init('read-meter-info')
      }
    }
  },
  ready () {
    this.$refs.route.init('home-page')
    this.showTop = false
  },
  methods: {
    backPage () {

    }
  }
}
</script>
<style>
  .have_top {
    padding-top: 60px;
  }
</style>
